package com.everyday;

import java.util.*;
import java.util.Comparator;

public class Solution2367 {
    public int arithmeticTriplets(int[] nums, int diff) {
        Set<Integer> set = new HashSet<>();
        for (int num : nums) {
            set.add(num);
        }
        int res = 0;
        for (int num : nums) {
            if (set.contains(num - diff) && set.contains(num + diff)) res++;
        }
        return res;
    }
}
